package root.electronclass.electronclass.home.widget;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.viewpager2.widget.ViewPager2;

public class CardPageTransformer implements ViewPager2.PageTransformer {
    private static final float MIN_SCALE = 0.85f;
    private static final float MIN_ALPHA = 0.7f;

    @Override
    public void transformPage(@NonNull View page, float position) {
        float scale = Math.max(MIN_SCALE, 1 - Math.abs(position) * 0.15f);
        float alpha = Math.max(MIN_ALPHA, 1 - Math.abs(position) * 0.3f);
        page.setScaleY(scale);
        page.setScaleX(scale);
        page.setAlpha(alpha);
        page.setTranslationZ(position == 0 ? 1 : 0); // 让中间卡片在最上层
    }

}